<?php


class Sherpa_MainnavigationController extends WSB_Xtension_Content
{

	/**
	 * @return string
	 */
	public function renderForBackend()
	{
		return get_class($this);
	}

	/**
	 * Index Action
	 */
	public function indexAction()
	{
		$tree = WSB_Node_Page::getTree();
		$pageId = WSB_Frontend::getInstance()->getPageId();
		if($pageId > 0) {
			$rootline = $tree->getRootlinePageIds($pageId);
			$activeFirstLevelPage = null;
			if(count($rootline) >= 2) {
				array_pop($rootline);
				$activeFirstLevelPage = $tree->getPage(array_pop($rootline));
				if(!empty($activeFirstLevelPage->nav_hide)) {
					$activeFirstLevelPage = null;
				}
			}
			$this->assignToView('pageId', $pageId);
			$this->assignToView('activeFirstLevelPage', $activeFirstLevelPage);
			$this->assignToView('rootline', '');
			$this->renderView('mainnavigation/index.phtml');
		}
	}

}